<%@ Import Namespace="System.IO" %>
<script  runat="server">
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)
Dim path As String = "c:\temp\MyTest.txt"
        Dim path2 As String = path + "temp"
        Dim fi As FileInfo = New FileInfo(path)

        If fi.Exists = False Then
            'Create a file to write to.
            Dim sw As StreamWriter = fi.CreateText()

            sw.WriteLine("Hello")
            sw.WriteLine("And")
            sw.WriteLine("Welcome")
            sw.Flush()
            sw.Close()
        End If

        Try
            'Open the file to read from.
            Dim sr As StreamReader = fi.OpenText()

            Do While sr.Peek() >= 0
                Response.Write(sr.ReadLine())
            Loop
            sr.Close()
            Dim fi2 As FileInfo = New FileInfo(path2)

            'Ensure that the target does not exist.
            fi2.Delete()

            'Copy the file.
            fi.CopyTo(path2)
            Response.Write( _
	"The process was copied to " + path + _
	path2)

            'Delete the newly created file.
            fi2.Delete()
            Response.Write( _
	"The process was successfully deleted." + _
	path2)


        Catch err As Exception
            Response.Write( _
	"<br>The process failed:" + err.ToString())
        End Try

End Sub
</script>


